function Measurements = MeasureIn(SessionFT,Masks,ScatterMasks,GaussianDeback)
import OBT5.*
HasScatter=exist('ScatterMasks','var');
if HasScatter
	HasGaussian=exist('GaussianDeback','var');
	if ~(HasGaussian||iscell(ScatterMasks))
		GaussianDeback=ScatterMasks;
		HasScatter=false;
		HasGaussian=true;
	end
else
	HasGaussian=false;
end
FTTimes=SessionFT.Time;
UniqueTimes=unique(FTTimes);
NoUT=numel(UniqueTimes);
[SizeG,SizeZ]=size(Masks);
SessionMeasurements=cell(SizeG,SizeZ,NoUT);
FirstTrial=true;
for Ti=1:NoUT
	FilePaths=sortrows(SessionFT(FTTimes==UniqueTimes(Ti),:),"Trial").FilePath;
	NoTrials=numel(FilePaths);
	TimeMeasurements=cell(SizeG,SizeZ,NoTrials);
	for Tr=1:NoTrials
		Data=OmeBigTiff5D.Create(FilePaths(Tr),CreationDisposition.OpenExisting).ReadPixels5D;
		if HasGaussian
			GaussianBack=imgaussfilt(Data,GaussianDeback);
			Data=Data-GaussianBack+mean(GaussianBack,[1 2]);
		end
		if FirstTrial
			[SizeY,SizeX]=size(Data,1,2);
			FirstTrial=false;
		end
		Data=double(reshape(Data-min(0,min(Data,[],"all")),SizeY*SizeX,[],SizeZ));
		for Z=1:SizeZ
			ZData=Data(:,:,Z);
			for G=1:SizeG
				M=Masks{G,Z}*ZData;
				if HasScatter
					Scatters=ScatterMasks{G,Z}*ZData;
					M=M-Scatters+mean(Scatters,2);
				end
				TimeMeasurements{G,Z,Tr}=M;
			end
		end
	end
	for Z=1:SizeZ
		for G=1:SizeG
			SessionMeasurements{G,Z,Ti}=cat(3,TimeMeasurements{G,Z,:});
		end
	end
end
Measurements={UniqueTimes SessionMeasurements};